from rest_framework.fields import SerializerMethodField
from rest_framework.serializers import ModelSerializer

from cart.models import CartModel


class CartSer(ModelSerializer):
    calist=SerializerMethodField(read_only=True)
    def get_calist(self,obj):
        return ({
            "name":obj.course.name,
            "cover":obj.course.cover,
            "price":obj.course.price,
            "level":obj.course.level,
        })
    class Meta:
        model=CartModel
        fields='__all__'